﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Net.Sockets; 

namespace ChatClient
{

    public partial class frmSendFile : Form
    {

        IPAddress ipAddr;

        public frmSendFile()
        {
            InitializeComponent();
        }

        private void frmSendFile_Load(object sender, EventArgs e)
        {
            ipAddr = IPAddress.Parse("203.52.93.90");
        }

        private void brnBrowse_Click(object sender, EventArgs e)
        {  
            OpenFileDialog ofpd = new OpenFileDialog();
            ofpd.ShowDialog();
            txtFileName.Text = ofpd.FileName;
        }

        private void btnSend_Click(object sender, EventArgs e)
        {
            Stream Fs = File.OpenRead(txtFileName.Text);
            Byte[] buffer = new Byte[Fs.Length];
            Fs.Read(buffer, 0, buffer.Length);
            TcpClient socket = new TcpClient();
            socket.Connect(ipAddr, 1095);
            NetworkStream nw = socket.GetStream();
            nw.Write(buffer, 0, buffer.Length);
            nw.Close();
            this.Close();
        }
    }
}
